package com.chookss.tiku.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chookss.R;

import java.util.List;

/**
 * 项目名：  ListViewLinkage
 * 描述：    左侧Adapter
 */
public class BottomListsAdapter extends BaseAdapter {
    //标题
    private List<String> datas;
    private LayoutInflater inflater;
    private int selectPosition=-1;
    public BottomListsAdapter(Context mContext, List<String> datas) {
        this.datas = datas;
        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            //加载
            convertView = inflater.inflate(R.layout.lv_item_bottom, parent, false);
            //绑定
            holder.lv_bottom_item_text = (TextView) convertView.findViewById(R.id.lv_bottom_item_text);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        //设置数据
        holder.lv_bottom_item_text.setText(datas.get(position));
        if(selectPosition==position){
            holder.lv_bottom_item_text.setTextColor(Color.parseColor("#E12416"));
        }else{
            holder.lv_bottom_item_text.setTextColor(Color.parseColor("#333333"));
        }
        return convertView;
    }

    public void setSelect(int position) {
        this.selectPosition = position;
        notifyDataSetChanged();
    }
    class ViewHolder {
        private TextView lv_bottom_item_text;
    }
}